<?php
  
    class Core{
    	
		protected $smarty;
		
		protected $template_dir;
		
		protected $mod;
		
		protected $_T;
		
		protected $plugIn;
		
		public function __construct(){
			$this->smarty                 =    new Smarty();	
			$this->smarty->config_dir     =    "App/common/libs/Config_File.class.php";
			$this->smarty->compile_dir    =    "App/compiled/";
			$this->smarty->cache_dir      =    "App/cashe/";
			$this->smarty->template_dir = "";
			$this->smarty->caching        =    false;             //开启缓存,为flase的时侯缓存无效
			$this->smarty->cache_lifetime =    50;                //缓存时间
			$this->smarty->left_delimiter =    "<!--{";
			$this->smarty->right_delimiter=    "}!-->";	
			$this->template_dir  =  "";
			$this->mod           = "";
			$this->_T            = array();
			$this->plugIn        = "APP/service";    //第三方插件所在文件夹
		}
		
		public function setTemplateDir($template_dir){
			//$this->smarty->template_dir   =    "./views/".$template_dir;
			$this->template_dir = "APP/view/".$template_dir."/";
		}
		
		public function getPlugIn(){
			$plugInArray =$this->setPlugIn();
			if(!is_array($plugInArray))
				return NULL;
			for($i=0;$i<count($plugInArray);$i++){
				$plugInArray[$i] = $this->plugIn."/".$plugInArray[$i];
			}
			return $plugInArray;
		}
		
		public function showmessage($msg,$url,$time = 3000,$gowhere){
			if($url == "goback"){
	   			$url = "history.go(-1)";
				$link = 'href="javascript:void(0)" onclick="history.go(-1)"';
				$gowhere = "返回"; 
	   		}else{
	   			$link = "href='".$url."'";
	   			$url = 'location.href="'.$url.'"';
	   		}
			$this->_T = array();
			$this->_T['css']   = "APP/view/global/jump/css/";
			$this->_T['js']    = "APP/view/global/jump/js/";
			$this->_T['image'] = "APP/view/global/jump/images/";
			$this->_T['msg']   = $msg;
			$this->_T['link']  = $link;
			$this->_T['url']   = $url;
			$this->_T['time']  = $time;
			$this->_T['gowhere']= $gowhere;
			$this->smarty->assign("T",$this->_T);		
			$this->smarty->display("APP/view/global/jump/jump.html");	
			exit;
		}
		
		protected function setPlugIn(){
			return null;
		}
		
		protected function template($common){
			$common_template_url = $this->template_dir;
			if($common=="parent"){
				$template_dir_array = explode("/",$this->template_dir);
				unset($template_dir_array[count($template_dir_array)-2]);
				$common_template_url = implode("/",$template_dir_array);
				$this->_T['css']   = $common_template_url."css/";
				$this->_T['image'] = $common_template_url."images/";
				$this->_T['js']    = $common_template_url."js/";
			}else{
				$this->_T['css']   = $this->template_dir."css/";
				$this->_T['image'] = $this->template_dir."images/";
				$this->_T['js']    = $this->template_dir."js/";
			}
			$this->smarty->assign("T",$this->_T);
			$this->smarty->display($common_template_url."Header.html");
			$this->smarty->display($this->template_dir.$this->mod.".html");
			$this->smarty->display($common_template_url."Footer.html");
		}

    }







?>